<?php
/**
 * Created by PhpStorm.
 * User: 王松
 * Time: 2017/8/10 09:45
 */

namespace App\Models\Reservation;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Silber\Bouncer\Database\Role as Bouncer;

class Role extends Bouncer
{
    public function scopeDoctors(Builder $builder, $hospital_id)
    {
        return $builder->with(['users' => function (MorphToMany $morphToMany) use ($hospital_id) {

            $morphToMany->where('hospital_id', $hospital_id)->select(['id', 'name', 'hospital_id']);
        }]);
    }
}